pub mod cpp_imports;

pub use cpp_imports::tis_grabber::*;

#[cfg(test)]
mod tests {
    use core::panic;

    use super::*;

    #[test]
    fn ic_open_device() {
        unsafe {
            let init_status = IC_InitLibrary(std::ptr::from_mut(&mut 0));
            if init_status != IC_SUCCESS as i32 {
                panic!("Failed to init library! status: {}", init_status);
            }
            let mut h_grabber = IC_CreateGrabber();
            if h_grabber.is_null() {
                panic!("h_grabber is NULL!");
            }
            let mut device = "DFK 21F04".to_string();
            let open_result = IC_OpenVideoCaptureDevice(h_grabber, device.as_mut_ptr() as *mut i8);
            if open_result == IC_SUCCESS as i32 {
                // .. do something with the video capture device.

                // Now clean up.
            }
            IC_CloseVideoCaptureDevice(h_grabber);
            IC_ReleaseGrabber(std::ptr::from_mut(&mut h_grabber));

            IC_CloseLibrary();
        }
    }
}
